/*点击验证码进行刷新*/
function flushCode() {
    document.getElementById("getCode").src = "http://localhost:8080/code?date=" + new Date();
}

function zhuce() {
    window.location.href = "../userRegister.html"
}

/*登录按钮操作*/
function login() {
    let username = $("#username").val();
    let password = $("#password").val();
    let code = $("#code").val();
    let reg = /^[a-zA-Z]\w{5,15}$/;
    if (!reg.test(password)) {
        alert("您输入的密码格式不正确！");
        return;
    }
    let data = {
        username: username,
        password: password,
        code: code
    };
    let result = myAjax('/login', 'post', data);
    /*
           * 逻辑：通过数据判断用户信息是否匹配和正确，如果是跳转到下个界面，如果不正确提示错误请重新输入
           * */
    if (result === 1) {
        window.location.href = "/back/manage.html";
        $.cookie("token", username);
    } else if (result === 0) {
        alert("您输入的用户名或者密码不正确");
    } else {
        alert("验证码输入错误！")
    }
}
